//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.baidu.trace;

import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Process;
import android.os.RemoteException;
import android.text.TextUtils;
import com.baidu.lbsapi.auth.tracesdk.LBSAuthManager;
import com.baidu.trace.IListener.Stub;
import com.baidu.trace.api.analysis.DrivingBehaviorRequest;
import com.baidu.trace.api.analysis.OnAnalysisListener;
import com.baidu.trace.api.analysis.StayPointRequest;
import com.baidu.trace.api.bos.BosGeneratePresignedUrlRequest;
import com.baidu.trace.api.bos.BosGetObjectRequest;
import com.baidu.trace.api.bos.BosPutObjectRequest;
import com.baidu.trace.api.bos.OnBosListener;
import com.baidu.trace.api.entity.AddEntityRequest;
import com.baidu.trace.api.entity.AroundSearchRequest;
import com.baidu.trace.api.entity.BoundSearchRequest;
import com.baidu.trace.api.entity.DeleteEntityRequest;
import com.baidu.trace.api.entity.DistrictSearchRequest;
import com.baidu.trace.api.entity.EntityListRequest;
import com.baidu.trace.api.entity.LocRequest;
import com.baidu.trace.api.entity.OnEntityListener;
import com.baidu.trace.api.entity.PolygonSearchRequest;
import com.baidu.trace.api.entity.SearchRequest;
import com.baidu.trace.api.entity.UpdateEntityRequest;
import com.baidu.trace.api.fence.AlarmPoint;
import com.baidu.trace.api.fence.CreateFenceRequest;
import com.baidu.trace.api.fence.DeleteFenceRequest;
import com.baidu.trace.api.fence.FenceAlarmPushInfo;
import com.baidu.trace.api.fence.FenceListRequest;
import com.baidu.trace.api.fence.HistoryAlarmRequest;
import com.baidu.trace.api.fence.MonitoredAction;
import com.baidu.trace.api.fence.MonitoredStatusByLocationRequest;
import com.baidu.trace.api.fence.MonitoredStatusRequest;
import com.baidu.trace.api.fence.OnFenceListener;
import com.baidu.trace.api.fence.UpdateFenceRequest;
import com.baidu.trace.api.track.AddPointRequest;
import com.baidu.trace.api.track.AddPointsRequest;
import com.baidu.trace.api.track.ClearCacheTrackRequest;
import com.baidu.trace.api.track.ClearCacheTrackResponse;
import com.baidu.trace.api.track.DistanceRequest;
import com.baidu.trace.api.track.HistoryTrackRequest;
import com.baidu.trace.api.track.LatestPointRequest;
import com.baidu.trace.api.track.OnTrackListener;
import com.baidu.trace.api.track.QueryCacheTrackRequest;
import com.baidu.trace.api.track.QueryCacheTrackResponse;
import com.baidu.trace.c.e;
import com.baidu.trace.c.h;
import com.baidu.trace.model.CoordType;
import com.baidu.trace.model.LatLng;
import com.baidu.trace.model.LocType;
import com.baidu.trace.model.LocationMode;
import com.baidu.trace.model.OnCustomAttributeListener;
import com.baidu.trace.model.OnTraceListener;
import com.baidu.trace.model.ProtocolType;
import com.baidu.trace.model.PushMessage;
import com.baidu.trace.model.TraceLocation;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

public final class LBSTraceClient {
    private Context b;
    private Intent c = null;
    private IService d = null;
    private LBSTraceClient.ClientListener e = null;
    private LBSTraceClient.a f = new LBSTraceClient.a(this);
    private LocationMode g;
    private OnTraceListener h;
    private OnCustomAttributeListener i;
    private boolean j;
    private ar k;
    protected static LBSTraceClient a = null;
    private ServiceConnection l;

    public LBSTraceClient(Context var1) {
        this.g = LocationMode.High_Accuracy;
        this.h = null;
        this.i = null;
        this.j = false;
        this.k = null;
        this.l = new ap(this);
        this.b = var1.getApplicationContext();
        this.e = new LBSTraceClient.ClientListener(this);
        this.c();
    }

    public final boolean initThreadPoolConfig(int var1, int var2, int var3) {
        return com.baidu.trace.c.a.a(var1, var2, (long)var3);
    }

    public final void createFence(CreateFenceRequest var1, OnFenceListener var2) {
        if(com.baidu.trace.a.a("createFence", var1, var2)) {
            com.baidu.trace.a.a(this.b, this.d, this.f, var1, var2);
        }

    }

    public final void updateFence(UpdateFenceRequest var1, OnFenceListener var2) {
        if(com.baidu.trace.a.a("updateFence", var1, var2)) {
            com.baidu.trace.a.a(this.b, this.d, this.f, var1, var2);
        }

    }

    public final void deleteFence(DeleteFenceRequest var1, OnFenceListener var2) {
        if(com.baidu.trace.a.a("deleteFence", var1, var2)) {
            com.baidu.trace.a.a(this.b, this.d, this.f, var1, var2);
        }

    }

    public final void queryFenceList(FenceListRequest var1, OnFenceListener var2) {
        if(com.baidu.trace.a.a("queryFenceList", var1, var2)) {
            com.baidu.trace.a.a(this.b, this.f, var1, var2);
        }

    }

    public final void queryMonitoredStatus(MonitoredStatusRequest var1, OnFenceListener var2) {
        if(com.baidu.trace.a.a("queryMonitoredStatus", var1, var2)) {
            com.baidu.trace.a.a(this.b, this.f, var1, var2);
        }

    }

    public final void queryMonitoredStatusByLocation(MonitoredStatusByLocationRequest var1, OnFenceListener var2) {
        if(com.baidu.trace.a.a("queryMonitoredStatusByLocation", var1, var2)) {
            com.baidu.trace.a.a(this.b, this.f, var1, var2);
        }

    }

    public final void queryFenceHistoryAlarmInfo(HistoryAlarmRequest var1, OnFenceListener var2) {
        if(com.baidu.trace.a.a("queryFenceHistoryAlarmInfo", var1, var2)) {
            com.baidu.trace.a.a(this.b, this.f, var1, var2);
        }

    }

    public final void addEntity(AddEntityRequest var1, OnEntityListener var2) {
        if(com.baidu.trace.a.a("addEntity", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void updateEntity(UpdateEntityRequest var1, OnEntityListener var2) {
        if(com.baidu.trace.a.a("updateEntity", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void deleteEntity(DeleteEntityRequest var1, OnEntityListener var2) {
        if(com.baidu.trace.a.a("deleteEntity", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void queryEntityList(EntityListRequest var1, OnEntityListener var2) {
        if(com.baidu.trace.a.a("queryEntityList", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void searchEntity(SearchRequest var1, OnEntityListener var2) {
        if(com.baidu.trace.a.a("searchEntity", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void boundSearchEntity(BoundSearchRequest var1, OnEntityListener var2) {
        if(com.baidu.trace.a.a("boundSearchEntity", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void aroundSearchEntity(AroundSearchRequest var1, OnEntityListener var2) {
        if(com.baidu.trace.a.a("aroundSearchEntity", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void polygonSearchEntity(PolygonSearchRequest var1, OnEntityListener var2) {
        if(com.baidu.trace.a.a("polygonSearchRequest", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void districtSearchEntity(DistrictSearchRequest var1, OnEntityListener var2) {
        if(com.baidu.trace.a.a("districtSearchRequest", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void addPoint(AddPointRequest var1, OnTrackListener var2) {
        if(com.baidu.trace.a.a("addPoint", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void addPoints(AddPointsRequest var1, OnTrackListener var2) {
        if(com.baidu.trace.a.a("addPoints", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void queryHistoryTrack(HistoryTrackRequest var1, OnTrackListener var2) {
        if(com.baidu.trace.a.a("queryHistoryTrack", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void queryDistance(DistanceRequest var1, OnTrackListener var2) {
        if(com.baidu.trace.a.a("queryDistance", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void queryLatestPoint(LatestPointRequest var1, OnTrackListener var2) {
        if(com.baidu.trace.a.a("queryLatestPoint", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void putObject(BosPutObjectRequest var1, OnBosListener var2) {
        if(com.baidu.trace.a.a("putObject", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void getObject(BosGetObjectRequest var1, OnBosListener var2) {
        if(com.baidu.trace.a.a("getObject", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void generatePresignedUrl(BosGeneratePresignedUrlRequest var1, OnBosListener var2) {
        if(com.baidu.trace.a.a("generatePresignedUrl", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void queryStayPoint(StayPointRequest var1, OnAnalysisListener var2) {
        if(com.baidu.trace.a.a("queryStayPoint", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void queryDrivingBehavior(DrivingBehaviorRequest var1, OnAnalysisListener var2) {
        if(com.baidu.trace.a.a("queryDrivingBehavior", var1, var2)) {
            com.baidu.trace.a.a(var1, var2);
        }

    }

    public final void queryRealTimeLoc(LocRequest var1, OnEntityListener var2) {
        if(com.baidu.trace.a.a("queryRealTimeLoc", var1, var2)) {
            if(this.k == null) {
                Class var3 = LBSTraceClient.class;
                synchronized(LBSTraceClient.class) {
                    if(this.k == null) {
                        this.k = new ar(this.b, this.f);
                    }
                }
            }

            TraceLocation var5 = new TraceLocation(var1.getTag(), 0, "成功", "", "", "", 0.0D, 0.0D, CoordType.bd09ll, 0.0D, 0.0F, 0.0F, 0, "");
            if(this.k.a(this.b, this.f, var5)) {
                if(!var1.isCanceled()) {
                    var5.setLocType(LocType.GPS);
                    var2.onReceiveLocation(var5);
                    return;
                }
            } else {
                aa.a(this.b, var1, var2);
            }

        }
    }

    public final void stopRealTimeLoc() {
        if(this.k != null) {
            this.k.b();
        }

    }

    public final void queryCacheTrack(QueryCacheTrackRequest var1, OnTrackListener var2) {
        if(com.baidu.trace.a.a("queryCacheTrack", var1, var2)) {
            OnTrackListener var4 = var2;
            LBSTraceClient.a var3 = this.f;
            QueryCacheTrackRequest var7 = var1;
            Context var6 = this.b;
            QueryCacheTrackResponse var5 = new QueryCacheTrackResponse(var7.getTag(), 0, "成功");
            com.baidu.trace.c.a.a.execute(new be(var6, var7, var5, var3, var4));
        }

    }

    public final void clearCacheTrack(ClearCacheTrackRequest var1, OnTrackListener var2) {
        if(com.baidu.trace.a.a("clearCacheTrack", var1, var2)) {
            OnTrackListener var4 = var2;
            LBSTraceClient.a var3 = this.f;
            ClearCacheTrackRequest var8 = var1;
            Context var7 = this.b;
            ClearCacheTrackResponse var5 = new ClearCacheTrackResponse(var8.getTag(), 0, "成功");
            List var6 = var8.getEntityNames();
            List var9 = var8.getCacheTrackInfos();
            com.baidu.trace.c.a.a.execute(new bg(var7, var6, var9, var5, var3, var4));
        }

    }

    public final LBSTraceClient setProtocolType(ProtocolType var1) {
        com.baidu.trace.c.a.b = var1 == null?ProtocolType.HTTPS:var1;
        if(this.d == null) {
            return this;
        } else {
            try {
                this.d.setProtocolType(com.baidu.trace.c.a.b.ordinal());
            } catch (Exception var2) {
                ;
            }

            return this;
        }
    }

    public final LBSTraceClient setLocationMode(LocationMode var1) {
        this.g = var1 == null?LocationMode.High_Accuracy:var1;
        if(this.d == null) {
            return this;
        } else {
            try {
                this.d.setLocationMode(this.g.ordinal());
            } catch (Exception var2) {
                ;
            }

            return this;
        }
    }

    public final boolean setInterval(int var1, int var2) {
        if(var1 > 0 && var1 <= 300 && var2 >= var1 && var2 >= 2 && var2 <= 300 && var2 % var1 == 0) {
            boolean var3 = Trace.a(var1, var2);
            if(this.d == null) {
                return var3;
            } else {
                try {
                    return this.d.setInterval(var1, var2);
                } catch (Exception var4) {
                    return false;
                }
            }
        } else {
            return false;
        }
    }

    public final boolean setLocTimeOffset(int var1) {
        if(var1 <= 0) {
            return false;
        } else {
            boolean var2 = Trace.b(var1);
            if(this.d == null) {
                return var2;
            } else {
                try {
                    return this.d.setLocTimeOffset(var1);
                } catch (Exception var3) {
                    return false;
                }
            }
        }
    }

    public final boolean setCacheSize(int var1) {
        if(var1 < 50) {
            return false;
        } else if(this.d == null) {
            if(Trace.a(var1)) {
                am.a(var1);
                return true;
            } else {
                return false;
            }
        } else {
            try {
                if(this.d.setCacheSize(var1)) {
                    am.a(var1);
                    return true;
                } else {
                    return false;
                }
            } catch (Exception var2) {
                return false;
            }
        }
    }

    protected final void a() {
        try {
            this.d.handleExtendedOperate(0);
        } catch (Exception var1) {
            ;
        }
    }

    public final void setOnTraceListener(OnTraceListener var1) {
        this.h = var1;
    }

    public final void setOnCustomAttributeListener(OnCustomAttributeListener var1) {
        this.i = var1;
    }

    public final void startTrace(Trace var1, OnTraceListener var2) {
        if(var1 == null) {
            com.baidu.trace.a.a("BaiduTraceSDK", "Trace instance is null");
        } else {
            if(var2 != null) {
                this.h = var2;
            }

            try {
                this.c();
                if(a == null) {
                    a = this;
                }

                long var5;
                if((var5 = var1.getServiceId()) <= 0L) {
                    if(this.h != null) {
                        this.h.onStartTraceCallback(10002, "service_id参数错误");
                        com.baidu.trace.a.a("BaiduTraceSDK", "serviceId is invalid");
                    }
                } else {
                    z.b = var5;
                    String var3;
                    if(TextUtils.isEmpty(var3 = d.b.getKey())) {
                        if(this.h != null) {
                            this.h.onStartTraceCallback(10002, "ak参数错误");
                            com.baidu.trace.a.a("BaiduTraceSDK", "ak is empty string or null");
                        }
                    } else {
                        String var4;
                        if(e.a(var4 = var1.getEntityName())) {
                            if(this.c == null) {
                                this.c = new Intent(this.b, LBSTraceService.class);
                            }

                            Bundle var7;
                            (var7 = new Bundle()).putInt("locationMode", this.g.ordinal());
                            var7.putInt("protocolType", com.baidu.trace.c.a.b.ordinal());
                            var7.putInt("gatherInterval", Trace.a);
                            var7.putInt("packInterval", Trace.b);
                            var7.putInt("locTimeOffset", Trace.d);
                            var7.putLong("serviceId", var5);
                            var7.putBoolean("isNeedObjectStorage", var1.isNeedObjectStorage());
                            var7.putString("ak", var3);
                            var7.putString("entityName", var4);
                            var7.putString("mcode", d.b.getMCode());
                            var7.putString("pcn", e.c(this.b));
                            if(50 <= Trace.c) {
                                var7.putInt("cacheSize", Trace.c);
                            }

                            if(null != var1.getNotification()) {
                                var7.putParcelable("notification", var1.getNotification());
                            }

                            this.c.putExtra("initData", var7);
                            this.c.putExtra("operateType", 0);
                            this.c.putExtra("processID", Process.myPid());
                            this.b();
                            return;
                        }

                        if(this.h != null) {
                            this.h.onStartTraceCallback(10002, "entity_name参数错误");
                            com.baidu.trace.a.a("BaiduTraceSDK", "entityName is empty string or null");
                        }
                    }
                }
            } catch (Exception var8) {
                if(this.h != null) {
                    this.h.onStartTraceCallback(10000, "请求发送失败");
                }
            }

        }
    }

    public final void stopTrace(Trace var1, OnTraceListener var2) {
        if(var1 == null) {
            com.baidu.trace.a.a("BaiduTraceSDK", "Trace instance is null");
        } else {
            if(var2 != null) {
                this.h = var2;
            }

            if(this.d == null) {
                if(this.h != null) {
                    this.h.onStopTraceCallback(11002, "服务未开启");
                }

            } else {
                try {
                    this.d.stopTrace(var1.getServiceId(), var1.getEntityName());
                } catch (Exception var4) {
                    if(this.h != null) {
                        this.h.onStopTraceCallback(11000, "请求发送失败");
                    }

                }
            }
        }
    }

    public final void startGather(OnTraceListener var1) {
        if(var1 != null) {
            this.h = var1;
        }

        if(this.d == null) {
            if(e.a(this.b, LBSTraceService.class.getName())) {
                if(this.c == null) {
                    this.c = new Intent(this.b, LBSTraceService.class);
                }

                this.c.putExtra("operateType", 1);
                this.b();
            } else {
                if(this.h != null) {
                    this.h.onStartGatherCallback(12002, "服务未开启");
                }

            }
        } else {
            try {
                int var4 = this.d.startGather();
                if(this.h == null) {
                    return;
                }

                if(52 == var4) {
                    this.h.onStartGatherCallback(0, "成功");
                } else {
                    if(54 != var4) {
                        this.h.onStartGatherCallback(12001, "采集开启失败");
                        return;
                    }

                    this.h.onStartGatherCallback(12003, "采集已开启");
                }
            } catch (Exception var3) {
                if(this.h == null) {
                    return;
                }

                if(!e.a(this.b, LBSTraceService.class.getName())) {
                    this.h.onStartGatherCallback(12002, "服务未开启");
                    return;
                }

                this.h.onStartGatherCallback(12000, "请求发送失败");
            }

        }
    }

    public final void stopGather(OnTraceListener var1) {
        if(var1 != null) {
            this.h = var1;
        }

        if(this.d == null) {
            if(e.a(this.b, LBSTraceService.class.getName())) {
                if(this.c == null) {
                    this.c = new Intent(this.b, LBSTraceService.class);
                }

                this.c.putExtra("operateType", 2);
                this.b();
            } else {
                if(this.h != null) {
                    this.h.onStopGatherCallback(13002, "服务未开启");
                }

            }
        } else {
            try {
                int var4 = this.d.stopGather();
                if(this.h == null) {
                    return;
                }

                if(55 == var4) {
                    this.h.onStopGatherCallback(0, "成功");
                } else {
                    if(57 != var4) {
                        this.h.onStopGatherCallback(13001, "采集停止失败");
                        return;
                    }

                    this.h.onStopGatherCallback(13003, "采集已停止");
                }
            } catch (Exception var3) {
                if(this.h == null) {
                    return;
                }

                if(!e.a(this.b, LBSTraceService.class.getName())) {
                    this.h.onStopGatherCallback(13002, "服务未开启");
                    return;
                }

                this.h.onStartGatherCallback(13000, "请求发送失败");
            }

        }
    }

    private void b() {
        try {
            this.b.startService(this.c);
            this.b.bindService(this.c, this.l, 1);
        } catch (Exception var3) {
            StringWriter var2 = new StringWriter();
            var3.printStackTrace(new PrintWriter(var2));
            com.baidu.trace.a.a("start and bind service failed, Exception : " + var2.toString());
            if(this.h != null) {
                this.h.onBindServiceCallback(1, "失败");
            }

        }
    }

    private void c() {
        if(!this.j) {
            this.j = true;
            av.a(this.b);
            d.b = LBSAuthManager.getInstance(this.b);
            q.a(this.b, d.b);
            e.a(this.b);
            com.baidu.trace.c.a.a(this.b, LBSTraceClient.class);
            am.a(this.b);
            String var10000 = e.c;
            h.b();
            d.a();
        }
    }

    public final void clear() {
        am.a();
        com.baidu.trace.c.a.a();
        d.b();
        if(this.k != null) {
            this.k.c();
            this.k = null;
        }

        a = null;
        this.j = false;
    }

    static class ClientListener extends Stub {
        private WeakReference<LBSTraceClient> traceClient = null;

        public ClientListener(LBSTraceClient var1) {
            this.traceClient = new WeakReference(var1);
        }

        public void startTraceCallback(int var1) throws RemoteException {
            this.sendMessage(var1);
        }

        public void stopTraceCallback(int var1) throws RemoteException {
            this.sendMessage(var1);
        }

        public void startGatherCallback(int var1) throws RemoteException {
            this.sendMessage(var1);
        }

        public void stopGatherCallback(int var1) throws RemoteException {
            this.sendMessage(var1);
        }

        public Map<String, String> gatherAttribute(long var1) throws RemoteException {
            LBSTraceClient var3 = (LBSTraceClient)this.traceClient.get();
            Map var4 = null;
            if(var3 != null && null != var3.i) {
                com.baidu.trace.a.a("LC-GPS locTime is: " + var1);
                var4 = var3.i.onTrackAttributeCallback(var1);
                if(var4 == null) {
                    var4 = var3.i.onTrackAttributeCallback();
                }
            }

            return var4;
        }

        public void pushCallback(byte var1, String var2) throws RemoteException {
            Message var3;
            (var3 = new Message()).arg1 = var1;
            var3.obj = var2;
            var3.what = 162;
            if(this.traceClient != null && null != ((LBSTraceClient)this.traceClient.get()).f) {
                ((LBSTraceClient)this.traceClient.get()).f.sendMessage(var3);
            }

        }

        public void extendedOperationCallback(int var1, String var2) throws RemoteException {
            if(var1 != 0) {
                this.sendMessage(172);
            } else {
                short var4 = 171;

                try {
                    JSONObject var5;
                    g.a = (var5 = new JSONObject(var2)).getString("accessKey");
                    g.c = var5.getString("secretKey");
                    g.d = var5.getString("token");
                    g.b = var5.getLong("expireTime");
                    com.baidu.trace.h.a();
                } catch (JSONException var3) {
                    var4 = 172;
                }

                this.sendMessage(var4);
            }
        }

        private void sendMessage(int var1) {
            Message var2;
            (var2 = new Message()).what = var1;
            if(this.traceClient != null && null != ((LBSTraceClient)this.traceClient.get()).f) {
                ((LBSTraceClient)this.traceClient.get()).f.sendMessage(var2);
            }

        }
    }

    static class a extends Handler {
        private WeakReference<LBSTraceClient> a = null;

        public a(LBSTraceClient var1) {
            this.a = new WeakReference(var1);
        }

        public final void handleMessage(Message var1) {
            super.handleMessage(var1);
            LBSTraceClient var2 = (LBSTraceClient)this.a.get();
            if(var2 == null) {
                com.baidu.trace.a.a("LBSTraceClient instance is null");
            } else {
                switch(var1.what) {
                    case 18:
                        if(null != var2.h) {
                            var2.h.onStartTraceCallback(10003, "网络连接失败");
                            return;
                        }
                        break;
                    case 19:
                        if(null != var2.h) {
                            var2.h.onStartTraceCallback(10004, "网络未开启");
                            return;
                        }
                        break;
                    case 22:
                        if(null != var2.h) {
                            var2.h.onStartTraceCallback(10005, "服务正在开启");
                            return;
                        }
                        break;
                    case 25:
                        if(null != var2.h) {
                            var2.h.onStartTraceCallback(10006, "服务已开启");
                            return;
                        }
                        break;
                    case 27:
                        if(null != var2.h) {
                            var2.h.onStopTraceCallback(11002, "服务未开启");
                            return;
                        }
                        break;
                    case 52:
                        if(null != var2.h) {
                            var2.h.onStartGatherCallback(0, "成功");
                            return;
                        }
                        break;
                    case 53:
                        if(null != var2.h) {
                            var2.h.onStartGatherCallback(12001, "采集开启失败");
                            return;
                        }
                        break;
                    case 54:
                        if(null != var2.h) {
                            var2.h.onStartGatherCallback(12003, "采集已开启");
                            return;
                        }
                        break;
                    case 55:
                        if(null != var2.h) {
                            var2.h.onStopGatherCallback(13003, "采集已停止");
                            return;
                        }
                        break;
                    case 56:
                        if(null != var2.h) {
                            var2.h.onStopGatherCallback(13001, "采集停止失败");
                            return;
                        }
                        break;
                    case 57:
                        if(null != var2.h) {
                            var2.h.onStopGatherCallback(0, "成功");
                            return;
                        }
                        break;
                    case 111:
                        return;
                    case 124:
                        if(null != var2.h) {
                            var2.h.onStartTraceCallback(0, "成功");
                            return;
                        }
                        break;
                    case 142:
                    case 143:
                        try {
                            try {
                                var2.d.unregisterListener();
                                var2.b.unbindService(var2.l);
                                var2.b.stopService(var2.c);
                                if(null != var2.h) {
                                    if(142 == var1.what) {
                                        var2.h.onStopTraceCallback(0, "成功");
                                    } else {
                                        var2.h.onStopTraceCallback(11004, "服务停止成功，还有未上传的缓存轨迹");
                                    }
                                }

                                var2.d = null;
                            } catch (Exception var15) {
                                StringWriter var19 = new StringWriter();
                                var15.printStackTrace(new PrintWriter(var19));
                                com.baidu.trace.a.a("unbind and stop LBSTraceService failed, Exception : " + var19.toString());
                                if(null != var2.h) {
                                    var2.h.onStopTraceCallback(11001, "服务停止失败");
                                }
                            }
                            break;
                        } finally {
                            h.a();
                        }
                    case 152:
                        if(null != var2.h) {
                            var2.h.onStopTraceCallback(11001, "服务停止失败");
                            return;
                        }
                        break;
                    case 162:
                        if(null == var2.h) {
                            return;
                        }

                        byte var3 = (byte)var1.arg1;
                        String var17 = (String)var1.obj;
                        PushMessage var4 = new PushMessage();
                        FenceAlarmPushInfo var5 = new FenceAlarmPushInfo();
                        FenceAlarmPushInfo var7 = var5;
                        String var6 = var17;
                        byte var18 = var3;

                        try {
                            JSONObject var20;
                            if((var20 = new JSONObject(var6)).has("fence_id")) {
                                var7.setFenceId(var20.getLong("fence_id"));
                            }

                            if(var20.has("fence")) {
                                var7.setFenceName(var20.getString("fence"));
                            }

                            if(var20.has("monitored_person")) {
                                var7.setMonitoredPerson(var20.getString("monitored_person"));
                            }

                            if(var20.has("action")) {
                                if(3 == var18) {
                                    switch(var20.getInt("action")) {
                                        case 1:
                                            var7.setMonitoredAction(MonitoredAction.enter);
                                            break;
                                        case 2:
                                            var7.setMonitoredAction(MonitoredAction.exit);
                                    }
                                } else if(4 == var18) {
                                    var7.setMonitoredAction(MonitoredAction.valueOf(var20.getString("action")));
                                }
                            }

                            AlarmPoint var8 = new AlarmPoint();
                            AlarmPoint var9 = new AlarmPoint();
                            if(var20.has("time")) {
                                var8.setLocTime(var20.getLong("time"));
                            }

                            if(var20.has("create_time")) {
                                var8.setCreateTime(var20.getLong("create_time"));
                            }

                            if(var20.has("latitude") && var20.has("longitude")) {
                                var8.setLocation(new LatLng(var20.getDouble("latitude"), var20.getDouble("longitude")));
                            }

                            if(var20.has("coord_type")) {
                                CoordType var10 = CoordType.bd09ll;
                                switch(var20.getInt("coord_type")) {
                                    case 1:
                                        var10 = CoordType.wgs84;
                                        break;
                                    case 2:
                                        var10 = CoordType.gcj02;
                                        break;
                                    case 3:
                                        var10 = CoordType.bd09ll;
                                }

                                var8.setCoordType(var10);
                            }

                            if(var20.has("radius")) {
                                var8.setRadius(var20.getDouble("radius"));
                            }

                            if(var20.has("cur_point")) {
                                com.baidu.trace.a.a(var20.getJSONObject("cur_point"), CoordType.bd09ll, var8, String.class);
                            }

                            var7.setCurrentPoint(var8);
                            if(var20.has("pre_point")) {
                                JSONObject var21 = var20.getJSONObject("pre_point");
                                if(3 == var18) {
                                    com.baidu.trace.a.a(var21, CoordType.bd09ll, var9, Integer.class);
                                } else if(4 == var18) {
                                    com.baidu.trace.a.a(var21, CoordType.bd09ll, var9, String.class);
                                }

                                var7.setPrePoint(var9);
                            }
                        } catch (Exception var14) {
                            ;
                        }

                        var4.setFenceAlarmPushInfo(var5);
                        var2.h.onPushCallback(var3, var4);
                        break;
                    case 171:
                        if(null != var2.h) {
                            var2.h.onInitBOSCallback(0, "成功");
                            return;
                        }
                        break;
                    case 172:
                        if(null != var2.h) {
                            var2.h.onInitBOSCallback(1, "失败");
                            return;
                        }
                        break;
                    case 181:
                        if(null != var2.h) {
                            var2.h.onStartTraceCallback(10007, "服务正在停止");
                            return;
                        }
                        break;
                    case 182:
                        if(null != var2.h) {
                            var2.h.onStopTraceCallback(11003, "服务正在停止");
                            return;
                        }
                        break;
                    case 1241:
                        if(null != var2.h) {
                            var2.h.onStartTraceCallback(10001, "服务开启失败");
                            return;
                        }
                        break;
                    case 10000:
                        if(null != var2.h) {
                            var2.h.onStartTraceCallback(10000, "请求发送失败");
                            return;
                        }
                }

            }
        }
    }
}
